<template>
	<view class="user-space-head u-f-ajc">
		<image class="bgimg" @tap.stop="changeBgImg" :src="getBgImg" mode="widthFix" lazy-load></image>
		<view class="user-space-head-info u-f-ajc u-f-column">
			<image class="headimg" :src="userinfo.userpic" mode="widthFix" lazy-load></image>
			<view class="user-space-margin nicheng u-f-ac">
				{{userinfo.username}}
				<tag-sex-age :sex="userinfo.sex" :age="userinfo.age"></tag-sex-age>
			</view>
			<view class="icon iconfont  user-space-head-btn user-space-margin "
				:class="[isguanzhu?'active ':'icon-zengjia']"
				@tap.stop="guanzhu">
				{{isguanzhu?'已关注':'关注'}}
			</view>
		</view>
	</view>
</template>

<script>
	import tagSexAge from "../../components/common/tag-sex-age.vue";
	export default {
		components:{
		    tagSexAge	
		},
		props:{
			userinfo:Object
		},
		data(){
			return {
				isguanzhu: this.userinfo.isguanzhu,
				bgimg: this.userinfo.bgimg
			}
		},
		computed:{
			getBgImg(){
				return '../../static/bgimg/'+this.bgimg+'.jpg';
			}
		},
		methods: {
			// 切换背景 
			changeBgImg(){
				let no = parseInt(this.bgimg);
				this.bgimg = no < 4 ? ++no :1;
			},
			guanzhu(){
				this.isguanzhu = !this.isguanzhu;
			}
		}
	}
</script>

<style scoped>

	
	.user-space-head {
		position: relative;
		height: 500upx;
		overflow: hidden;
	}
	
	.user-space-head .bgimg {
		width: 100%;
	}
	
	.user-space-head-info {
		position: absolute;
		top: 150upx;
	}
	
	.user-space-head-info .headimg{
		width: 150upx;
		height: 150upx;
		border-radius: 100%;
	}
	
	.user-space-head-info .nicheng {
		font-weight: bold;
		color: #FFFFFF;
		font-size: 35upx;
		text-shadow: 2upx 2upx 10upx #333333;
	}
	
	.user-space-head-btn {
		background: #FFE933;
		color: #333333;
		border: 1upx solid #FFE933;
		padding: 0 15upx;
		border-radius: 10upx;
		font-size: 28upx;
	}
	
	.active{
		background: none;
		color: #FFFFFF;
		border: 1upx solid #FFFFFF;
	}
</style>
